import App from './App'

// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'

import store from './store/index.js'
Vue.prototype.$store = store
//全局组件
//分割线
import divider from './components/common/divider.vue'
Vue.component('divider', divider)
//无数据
import nothing from './components/common/nothing.vue'
Vue.component('nothing', nothing)

//api挂载
import $C from './common/config.js'
Vue.prototype.$C = $C
//辅助工具类
import $U from './common/utils.js'
Vue.prototype.$U = $U
//挂在网络请求
import $H from './common/request.js'
Vue.prototype.$H = $H
//权限验证
Vue.prototype.checkAuth = (callback, checkPhone = true) => {
	if (!store.state.loginStuatus) {
		uni.showToast({
			title: '请先登录',
			icon: 'none'
		});
		return uni.navigateTo({
			url: "/pages/login/login",
		});
	}
	// 验证是否绑定手机号
	if (checkPhone && !store.state.userinfo.phone) {
		uni.showToast({
			title: '请绑定手机号',
			icon: 'none'
		});
		return uni.navigateTo({
			url: "/pages/user-phone/user-phone",
		});
	}
	callback()
}
//权限验证
Vue.prototype.navigateTo = (options) => {
	if (!store.state.loginStuatus) {
		uni.showToast({
			title: '请先登录',
			icon: 'none'
		});
		return uni.navigateTo({
			url: "/pages/login/login",
		});

	}
	uni.navigateTo(options)
}

const app = new Vue({
	store,
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app,
	}
}
// #endif
